class Main extends egret.DisplayObjectContainer {
    constructor() {
        super();
        this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAdd, this)
    }
    private onAdd() {
        try {
            this.runGame()
        }
        catch (error) {
            console.log(error);
        }

    }
    private async runGame() {
        await this.loadR();
        this.craGame()
    }
    private async loadR() {
        try {
            let loadConfigBar: LoadingUI = new LoadingUI;
            this.stage.addChild(loadConfigBar);
            await RES.loadConfig("resource/default.res.json", "resource/")
            await RES.loadGroup('preload', 0, loadConfigBar);
            this.stage.removeChild(loadConfigBar);
        } catch (error) {
            console.log(error);
        }

    }

    private craGame() {
        let bt:egret.Bitmap=new egret.Bitmap(RES.getRes("bg_jpg"));
        this.addChild(bt);
    }
}